import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import count from '@dfeidao/atom-nodejs/db/count';
import { systemid,productid} from '../../atom/config';
import complex_query from '@dfeidao/atom-nodejs/db/complex-query';
import get_field from '@dfeidao/atom-nodejs/data/get-field';

interface Message {
filter:{
	create_time:string[]
}
}


export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders){
	const arwr=[];
	const query = complex_query(action_id,session_id,systemid);
	for (let i = 0; i <6; i++) {
		const res = await query
		.add_fun('work_order', 'create_time', 'create_time', 'count')
		 // 大于3
		 .where_gt('work_order', 'create_time', message.filter.create_time[i])
		 // 小于
		 .where_lt('work_order', 'create_time',message.filter.create_time[i+1])
		.exec();
	const as= await get_field(res,'create_time');
	arwr.push(as);
	}
	return {arwr};
}
